<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateOpenShopSignOrder extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('open_shop_sign_order', function (Blueprint $table) {
            $table->id();

            $table->unsignedInteger('mainProcessId')->default(0)->comment('开店主流程id');
            $table->string('orderNo', 60)->default('')->comment('订单号');
            $table->unsignedTinyInteger('step')->default(1)->comment('步骤 1：用户基础信息 2：合同信息 3：部分支付 4：支付完成');
            $table->unsignedInteger('shouldPayPrice')->default(0)->comment('应付金额');
            $table->unsignedInteger('payPrice')->default(0)->comment('支付金额');
            $table->unsignedTinyInteger('payStatus')->default(0)->comment('支付状态 0-待支付 1 - 部分支付 2-支付完成');
            $table->unsignedInteger('signTime')->default(0)->comment('签约时间');

            $table->string('investmentManagerName', 60)->default('')->comment('招商经理名称');
            $table->unsignedInteger('investmentManagerId')->default(0)->comment('招商经理id');
            $table->unsignedTinyInteger('status')->default(1)->comment('订单状态 0-关闭 1 - 正常');
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');

            $table->collation = 'utf8mb4_general_ci';
            $table->unique(['orderNo'], 'orderNo');
            $table->unique(['mainProcessId'], 'idx_mainProcessId');
            $table->comment = '招商加盟 - 签约订单';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('open_shop_sign_order');
    }
}
